# -*- encoding: utf-8 -*-
"""

PyCharm filter函数.py
2024年10月20日10时48分
by wenyang

"""


def main():
    int_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    filter_items = filter(lambda x: x ** 2 > 10, int_list)
    print(filter_items)
    print(list(filter_items))
    print(list(filter_items)) # 此时返回的就是一个空列表 因为filter_items是一个迭代器对象 只能遍历一次
    names = ["wenyang", "xiaoming", "xiaohong"]
    ages = [17, 19, 20]
    gender = ["male", "female", "male"]
    zip_items = zip(names,ages, gender)
    filter_info_items = filter(lambda item: item[1] >= 18, list(zip_items))
    print(list(filter_info_items))


if __name__ == "__main__":
    main()
